package com.csun.dsms.controller;

import com.csun.dsms.comment.core.annotation.Authorization;
import com.csun.dsms.comment.core.support.CsunMessageSource;
import com.csun.dsms.comment.core.utils.wrapper.WrapMapper;
import com.csun.dsms.comment.core.utils.wrapper.Wrapper;
import com.csun.dsms.model.domain.DsmsLog;
import com.csun.dsms.model.domain.DsmsRecord;
import com.csun.dsms.model.dto.log.LogQueryDto;
import com.csun.dsms.model.dto.record.RecordQueryDto;
import com.csun.dsms.service.DsmsLogService;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author chisj chisj@foxmail.com
 * @version 1.0.0
 * @date 2021-09-01 11:33
 * @description: 日志拦截器
 */
public class DsmsLogController {

    @Resource
    private CsunMessageSource csunMessageSource;
    @Resource
    private DsmsLogService dsmsRecordList;

    /**
     * 查询日志列表 - 分页.
     *
     * @param logQueryDto the log query dto
     *
     * @return the wrapper
     */
    @Authorization
    @PostMapping(value = "/queryListWithPage")
    public Wrapper queryListWithPage(@RequestBody LogQueryDto logQueryDto) {

        List<DsmsLog> dsmsLogList = dsmsRecordList.queryListWithPage(logQueryDto);

        return WrapMapper.wrap(Wrapper.SUCCESS_CODE, csunMessageSource
                .getMessage("operation.success", null), new PageInfo(dsmsLogList));
    }

}
